/**
 * 
 */
package org.alipay4j.component.life;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.alipay4j.Alipay;
import org.alipay4j.AlipayException;
import org.alipay4j.Configuration;
import org.alipay4j.component.AbstractComponent;
import org.alipay4j.http.AlipayHttpsClient;
import org.alipay4j.http.Response;
import org.alipay4j.model.msg.Article;
import org.alipay4j.model.msg.Image;
import org.alipay4j.model.msg.MessageInfo;
import org.alipay4j.model.msg.MsgTemplate;
import org.alipay4j.model.msg.SendTemplate;
import org.alipay4j.model.msg.Text;
import org.alipay4j.util.ObjectHelper;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

/**
 * 消息管理组件
 * @author heliang
 *
 */
public class MessageComponent extends AbstractComponent {

	public MessageComponent(Alipay alipay) {
		super(alipay);
	}
	
	/**
	 * 消息模板领取接口
	 * 帮助服务窗开发者从服务窗平台（fuwu.alipay.com）公共模板库里领取一个行业的消息模板--消息模板是一种消息的样式，如消费提醒、账单提醒等
	 * @param template_id  消息母板id
	 * @return MsgTemplate 消息模板对象
	 * @throws AlipayException
	 */
	public MsgTemplate templateGet(String template_id) throws AlipayException {
		if (ObjectHelper.isEmpty(template_id)) {
            throw new IllegalArgumentException("template_id can't be null or empty");
        }
		//组装请求参数
		Map<String, String> body = new HashMap<String, String>();
		body.put("template_id", template_id);
		body.put("method", "alipay.open.public.template.message.get");
		Response response = new AlipayHttpsClient(super.alipay).postBizContent(body);
		//根据请求结果判定，是否验证成功
		JSONObject bodyRes = getObjRes(response, "alipay_open_public_template_message_get_response");
		if (Configuration.isDebug()) {
	        System.out.println("alipay_open_public_template_message_get_response返回json：" + bodyRes.toString());
	    }
	    String codeRes = bodyRes.getString("code");
	    if (ObjectHelper.isNotEmpty(codeRes)&&!"10000".equals(codeRes)) {
	    	String sub_code = bodyRes.getString("sub_code");
	    	String sub_msg = bodyRes.getString("sub_msg");
	        //返回异常信息
	        throw new AlipayException(getCause(sub_code,sub_msg));
	    }
	    MsgTemplate msgTemplate = JSONObject.toJavaObject(bodyRes, MsgTemplate.class);
		return msgTemplate;
	}
	
	/**
	 * 单发模板消息
	 * @param to_user_id  消息接收用户的userid
	 * @return boolean
	 * @throws AlipayException
	 */
	@SuppressWarnings("unchecked")
	public boolean singleSend(String to_user_id,SendTemplate template) throws AlipayException {
		if (ObjectHelper.isEmpty(to_user_id)) {
            throw new IllegalArgumentException("to_user_id can't be null or empty");
        }
		if (ObjectHelper.isEmpty(template)) {
            throw new IllegalArgumentException("template can't be null or empty");
        }
		//组装请求参数
		String bodyStr = JSONObject.toJSONString(template);
		Map<String, String> bodyMap = JSONObject.parseObject(bodyStr, Map.class);
		bodyMap.put("method", "alipay.open.public.template.message.get");
		Response response = new AlipayHttpsClient(super.alipay).post(bodyMap);
		//根据请求结果判定，是否验证成功
		JSONObject bodyRes = getObjRes(response, "alipay_open_public_message_single_send_response");
		if (Configuration.isDebug()) {
	        System.out.println("alipay_open_public_message_single_send_response返回json：" + bodyRes.toString());
	    }
	    String codeRes = bodyRes.getString("code");
	    if (ObjectHelper.isNotEmpty(codeRes)&&!"10000".equals(codeRes)) {
	    	String sub_code = bodyRes.getString("sub_code");
	    	String sub_msg = bodyRes.getString("sub_msg");
	        //返回异常信息
	        throw new AlipayException(getCause(sub_code,sub_msg));
	    }
		return true;
	}
	
	/**
	* @Title: 群发图文消息
	* @Description: 群发图文消息
	* @author heliang  
	* @param articles 图文消息 
	* @return message_id 消息ID
	* @throws AlipayException 
	 */
	public String totalSendArticle(List<Article> articles) throws AlipayException {
	    return totalSend("image-text", articles, null);
	}
	
	
	/**
    * @Title: 群发文本消息
    * @Description: 群发文本消息
    * @author heliang  
    * @param articles 图文消息 
    * @return message_id 消息ID
    * @throws AlipayException 
     */
    public String totalSendText(Text text) throws AlipayException {
        return totalSend("text", null, text);
    }
	
	/**
	 * 
	* @Title: 群发消息 
	* @Description: 群发消息
	* @author heliang 
	* @param msg_type 消息类型，text：文本消息，image-text：图文消息
	* @param articles 图文消息，当msg_type为image-text，该值必须设置
	* @param text 文本消息内容，当msg_type为text，必须设置该值
	* @return message_id 消息ID
	* @throws AlipayException 
	 */
    public String totalSend(String msg_type,List<Article> articles,Text text) throws AlipayException {
        if (ObjectHelper.isEmpty(msg_type)) {
            throw new IllegalArgumentException("msg_type can't be null or empty");
        }
        //组装请求参数
        Map<String, String> bodyMap = new HashMap<String, String>();
        bodyMap.put("msg_type", msg_type);
        if(ObjectHelper.isNotEmpty(articles)) {
            bodyMap.put("articles", JSONObject.toJSONString(articles));
        }
        if(ObjectHelper.isNotEmpty(text)) {
            bodyMap.put("text", JSONObject.toJSONString(text));
        }
        bodyMap.put("method", "alipay.open.public.message.total.send");
        Response response = new AlipayHttpsClient(super.alipay).post(bodyMap);
        //根据请求结果判定，是否验证成功
        JSONObject bodyRes = getObjRes(response, "alipay_open_public_message_total_send_response");
        if (Configuration.isDebug()) {
            System.out.println("alipay_open_public_message_total_send_response返回json：" + bodyRes.toString());
        }
        String codeRes = bodyRes.getString("code");
        if (ObjectHelper.isNotEmpty(codeRes)&&!"10000".equals(codeRes)) {
            String sub_code = bodyRes.getString("sub_code");
            String sub_msg = bodyRes.getString("sub_msg");
            //返回异常信息
            throw new AlipayException(getCause(sub_code,sub_msg));
        }
        return bodyRes.getString("message_id");
    }
	
    
    
    /**
     * @Title: 异步单发-图文消息
     * @Description: 异步单发-图文消息
     * @author heliang  
     * @param to_user_id 消息接收用户的userid
     * @param articles 图文消息 
     * @param chat 是否是聊天消息。支持值：0，1，当值为0时，代表是非聊天消息，消息显示在生活号主页，当值为1时，代表是聊天消息，消息显示在咨询反馈列表页。默认值为0
     * @param event_type 触发消息的事件类型，默认为空。代表商户未改造。如果是follow，代表关注消息。click代表菜单点击，enter_ppchat代表进入事件；请注意事件类型的大小写
     * @return boolean
     * @throws AlipayException 
      */
     public boolean customSendArticle(String to_user_id,List<Article> articles,String chat,String event_type) throws AlipayException {
         return customSend(to_user_id,"image-text", articles, null,chat,event_type);
     }
     
     
     /**
     * @Title: 异步单发文本消息
     * @Description: 群发文本消息
     * @author heliang  
     * @param to_user_id 消息接收用户的userid
     * @param text 文本消息
     * @param chat 是否是聊天消息。支持值：0，1，当值为0时，代表是非聊天消息，消息显示在生活号主页，当值为1时，代表是聊天消息，消息显示在咨询反馈列表页。默认值为0
     * @param event_type 触发消息的事件类型，默认为空。代表商户未改造。如果是follow，代表关注消息。click代表菜单点击，enter_ppchat代表进入事件；请注意事件类型的大小写
     * @return message_id 消息ID
     * @throws AlipayException 
      */
     public boolean customSendText(String to_user_id,Text text,String chat,String event_type) throws AlipayException {
         return customSend(to_user_id,"text", null, text,chat,event_type);
     }
    
    /**
    * @Title: 异步单发消息 
    * @Description: 异步单发消息
    * @author heliang
    * @param to_user_id 消息接收用户的userid
    * @param msg_type 消息类型，text：文本消息，image-text：图文消息
    * @param articles 图文消息
    * @param text 文本消息
    * @param chat 是否是聊天消息。支持值：0，1，当值为0时，代表是非聊天消息，消息显示在生活号主页，当值为1时，代表是聊天消息，消息显示在咨询反馈列表页。默认值为0
    * @param event_type 触发消息的事件类型，默认为空。代表商户未改造。如果是follow，代表关注消息。click代表菜单点击，enter_ppchat代表进入事件；请注意事件类型的大小写
    * @return boolean
    * @throws AlipayException 
     */
    public boolean customSend(String to_user_id,String msg_type,List<Article> articles,Text text,String chat,String event_type) throws AlipayException {
        if (ObjectHelper.isEmpty(to_user_id)) {
            throw new IllegalArgumentException("to_user_id can't be null or empty");
        }
        if (ObjectHelper.isEmpty(msg_type)) {
            throw new IllegalArgumentException("msg_type can't be null or empty");
        }
        //组装请求参数
        Map<String, String> bodyMap = new HashMap<String, String>();
        bodyMap.put("to_user_id", to_user_id);
        bodyMap.put("msg_type", msg_type);
        if(ObjectHelper.isNotEmpty(articles)) {
            bodyMap.put("articles", JSONObject.toJSONString(articles));
        }
        if(ObjectHelper.isNotEmpty(text)) {
            bodyMap.put("text", JSONObject.toJSONString(text));
        }
        bodyMap.put("chat", chat);
        bodyMap.put("event_type", event_type);
        bodyMap.put("method", "alipay.open.public.message.custom.send");
        Response response = new AlipayHttpsClient(super.alipay).post(bodyMap);
        //根据请求结果判定，是否验证成功
        JSONObject bodyRes = getObjRes(response, "alipay_open_public_message_custom_send_response");
        if (Configuration.isDebug()) {
            System.out.println("alipay_open_public_message_custom_send_response返回json：" + bodyRes.toString());
        }
        String codeRes = bodyRes.getString("code");
        if (ObjectHelper.isNotEmpty(codeRes)&&!"10000".equals(codeRes)) {
            String sub_code = bodyRes.getString("sub_code");
            String sub_msg = bodyRes.getString("sub_msg");
            //返回异常信息
            throw new AlipayException(getCause(sub_code,sub_msg));
        }
        return true;
    }
    
    /**
    * @Title: 分组发送图文 
    * @Description: 分组发送图文
    * @author heliang
    * @param group_id 分组id
    * @param articles 图文消息
    * @return message_id 消息id
    * @throws AlipayException
    */
    public String groupSendArticle(String group_id,List<Article> articles) throws AlipayException {
        return groupSend(group_id, "image-text", articles, null, null);
    }
    
    /**
    * @Title: 分组发送文字消息 
    * @Description: 分组发送文字消息
    * @author heliang
    * @param group_id 分组id
    * @param title 文本标题
    * @param content 文本内容
    * @return message_id 消息id
    * @throws AlipayException
    */
    public String groupSendText(String group_id,String title,String content) throws AlipayException {
        Text text = new Text(title, content);
        return groupSend(group_id, "text", null, text, null);
    }
    
    /**
    * @Title: 分组发送图片消息 
    * @Description: 分组发送图片消息
    * @author heliang
    * @param group_id 分组id
    * @param url  图片地址
    * @return message_id 消息id
    * @throws AlipayException 
     */
    public String groupSendImage(String group_id,String url) throws AlipayException {
        Image image = new Image();
        image.setUrl(url);
        return groupSend(group_id, "image", null, null, image);
    }
    
    /**
    * @Title: 分组消息发送接口 
    * @Description: 开发者可调用此接口向指定分组中的关注用户发送消息，该接口为异步接口，一般请求成功后一段时间用户才能收到消息。
    * @author heliang
    * @param group_id 用户分组ID
    * @param msg_type 消息类型，text表示文本消息，image-text表示图文消息
    * @param articles 图文消息
    * @param text 文本消息内容
    * @param image 纯图片消息
    * @return message_id 消息id
    * @throws AlipayException 
     */
    public String groupSend(String group_id,String msg_type,List<Article> articles,Text text,Image image) throws AlipayException {
        if (ObjectHelper.isEmpty(group_id)) {
            throw new IllegalArgumentException("group_id can't be null or empty");
        }
        if (ObjectHelper.isEmpty(msg_type)) {
            throw new IllegalArgumentException("msg_type can't be null or empty");
        }
        //组装请求参数
        Map<String, String> bodyMap = new HashMap<String, String>();
        bodyMap.put("group_id", group_id);
        bodyMap.put("msg_type", msg_type);
        if(ObjectHelper.isNotEmpty(articles)) {
            bodyMap.put("articles", JSONObject.toJSONString(articles));
        }
        if(ObjectHelper.isNotEmpty(text)) {
            bodyMap.put("text", JSONObject.toJSONString(text));
        }
        if(ObjectHelper.isNotEmpty(image)) {
            bodyMap.put("image", JSONObject.toJSONString(image));
        }
        bodyMap.put("method", "alipay.open.public.message.group.send");
        Response response = new AlipayHttpsClient(super.alipay).post(bodyMap);
        //根据请求结果判定，是否验证成功
        JSONObject bodyRes = getObjRes(response, "alipay_open_public_message_group_send_response");
        if (Configuration.isDebug()) {
            System.out.println("alipay_open_public_message_group_send_response返回json：" + bodyRes.toString());
        }
        String codeRes = bodyRes.getString("code");
        if (ObjectHelper.isNotEmpty(codeRes)&&!"10000".equals(codeRes)) {
            String sub_code = bodyRes.getString("sub_code");
            String sub_msg = bodyRes.getString("sub_msg");
            //返回异常信息
            throw new AlipayException(getCause(sub_code,sub_msg));
        }
        return bodyRes.getString("message_id");
    }

    /**
    * @Title: 生活号查询已发送消息接口 
    * @Description: 生活号查询已发送消息接口
    * @author heliang
    * @param message_ids 消息id集，限制最多传入20个message_id。message_id在调用群发、组发消息接口时会返回，需调用方保存
    * @return List<MessageInfo>
    * @throws AlipayException 
     */
    public List<MessageInfo> msgQueryByIds(String[] message_ids) throws AlipayException {
        if (ObjectHelper.isEmpty(message_ids)) {
            throw new IllegalArgumentException("message_ids can't be null or empty");
        }
        //组装请求参数
        Map<String, String> body = new HashMap<String, String>();
        body.put("message_ids", message_ids.toString());
        body.put("method", "alipay.open.public.message.query");
        Response response = new AlipayHttpsClient(super.alipay).postBizContent(body);
        //根据请求结果判定，是否验证成功
        JSONObject bodyRes = getObjRes(response, "alipay_open_public_message_query_response");
        if (Configuration.isDebug()) {
            System.out.println("alipay_open_public_message_query_response返回json：" + bodyRes.toString());
        }
        String codeRes = bodyRes.getString("code");
        if (ObjectHelper.isNotEmpty(codeRes)&&!"10000".equals(codeRes)) {
            String sub_code = bodyRes.getString("sub_code");
            String sub_msg = bodyRes.getString("sub_msg");
            //返回异常信息
            throw new AlipayException(getCause(sub_code,sub_msg));
        }
        List<MessageInfo> infos = new ArrayList<MessageInfo>();
        JSONArray array = bodyRes.getJSONArray("list");
        for(int i=0;i<array.size();i++) {
            MessageInfo info = JSONObject.toJavaObject(array.getJSONArray(i), MessageInfo.class);
            infos.add(info);
        }
        return infos;
    }
    
    /**
    * @Title: 生活号消息撤回接口 
    * @Description: 生活号消息撤回接口
    * @author heliang
    * @param message_id 消息id
    * @return boolean
    * @throws AlipayException 
     */
    public boolean recall(String message_id) throws AlipayException {
        if (ObjectHelper.isEmpty(message_id)) {
            throw new IllegalArgumentException("message_id can't be null or empty");
        }
        //组装请求参数
        Map<String, String> bodyMap = new HashMap<String, String>();
        bodyMap.put("message_id", message_id);
        bodyMap.put("method", "alipay.open.public.life.msg.recall");
        Response response = new AlipayHttpsClient(super.alipay).post(bodyMap);
        //根据请求结果判定，是否验证成功
        JSONObject bodyRes = getObjRes(response, "alipay_open_public_life_msg_recall_response");
        if (Configuration.isDebug()) {
            System.out.println("alipay_open_public_life_msg_recall_response返回json：" + bodyRes.toString());
        }
        String codeRes = bodyRes.getString("code");
        if (ObjectHelper.isNotEmpty(codeRes)&&!"10000".equals(codeRes)) {
            String sub_code = bodyRes.getString("sub_code");
            String sub_msg = bodyRes.getString("sub_msg");
            //返回异常信息
            throw new AlipayException(getCause(sub_code,sub_msg));
        }
        return true;
    }
    
    /**
    * @Title: 模板消息行业设置修改接口 
    * @Description: 用于修改服务窗消息模板设置的行业信息，如：IT科技/IT软件与服务。
    * @author heliang
    * @param primary_industry_name 服务窗消息模板所属主行业一/二级名称，查看行业信息
    * @param primary_industry_code 服务窗消息模板所属主行业一/二级编码
    * @param secondary_industry_code 服务窗消息模板所属副行业一/二级编码
    * @param secondary_industry_name 服务窗消息模板所属副行业一/二级名称
    * @return boolean
    * @throws AlipayException 
     */
    public boolean industryModify(String primary_industry_name,String primary_industry_code,
            String secondary_industry_code,String secondary_industry_name) throws AlipayException {
        if (ObjectHelper.isEmpty(primary_industry_name)) {
            throw new IllegalArgumentException("primary_industry_name can't be null or empty");
        }
        if (ObjectHelper.isEmpty(primary_industry_code)) {
            throw new IllegalArgumentException("primary_industry_code can't be null or empty");
        }
        if (ObjectHelper.isEmpty(secondary_industry_code)) {
            throw new IllegalArgumentException("secondary_industry_code can't be null or empty");
        }
        if (ObjectHelper.isEmpty(secondary_industry_name)) {
            throw new IllegalArgumentException("secondary_industry_name can't be null or empty");
        }
        //组装请求参数
        Map<String, String> bodyMap = new HashMap<String, String>();
        bodyMap.put("primary_industry_name", primary_industry_name);
        bodyMap.put("primary_industry_code", primary_industry_code);
        bodyMap.put("secondary_industry_code", secondary_industry_code);
        bodyMap.put("secondary_industry_name", secondary_industry_name);
        bodyMap.put("method", "alipay.open.public.template.message.industry.modify");
        Response response = new AlipayHttpsClient(super.alipay).post(bodyMap);
        //根据请求结果判定，是否验证成功
        JSONObject bodyRes = getObjRes(response, "alipay_open_public_template_message_industry_modify_response");
        if (Configuration.isDebug()) {
            System.out.println("alipay_open_public_template_message_industry_modify_response返回json：" + bodyRes.toString());
        }
        String codeRes = bodyRes.getString("code");
        if (ObjectHelper.isNotEmpty(codeRes)&&!"10000".equals(codeRes)) {
            String sub_code = bodyRes.getString("sub_code");
            String sub_msg = bodyRes.getString("sub_msg");
            //返回异常信息
            throw new AlipayException(getCause(sub_code,sub_msg));
        }
        return true;
    }
    
    
    /**
    * @Title: 创建图文消息内容接口
    * @Description: 开发者可使用该接口将富文本内容生成生活号图文消息内容链接
    * @author heliang 
    * @param title 标题
    * @param cover 封面图url
    * @param content 消息正文（支持富文本） 
    * @param could_comment 是否允许评论 T:允许 F:不允许，默认不允许  T
    * @param ctype 图文类型 activity: 活动图文，不填默认普通图文
    * @param benefit 活动利益点，图文类型ctype为activity类型时才需要传，最多10个字符
    * @param ext_tags 关键词列表，英文逗号分隔，最多不超过5个
    * @param login_ids 可预览支付宝账号列表，需要预览时才填写， 英文逗号分隔，最多不超过10个
    * @return JSONObject: {"code": "10000","msg": "Success","content_id": "201410323232dsadjada-dsa-1234dsada","content_url": "alipays://xxxx"}
    * @throws AlipayException 
     */
    public JSONObject articleCreate(String title,String cover,String content,String could_comment,
            String ctype,String benefit,String ext_tags,String login_ids) throws AlipayException {
        if (ObjectHelper.isEmpty(title)) {
            throw new IllegalArgumentException("title can't be null or empty");
        }
        if (ObjectHelper.isEmpty(cover)) {
            throw new IllegalArgumentException("cover can't be null or empty");
        }
        if (ObjectHelper.isEmpty(content)) {
            throw new IllegalArgumentException("content can't be null or empty");
        }
        //组装请求参数
        Map<String, String> bodyMap = new HashMap<String, String>();
        bodyMap.put("title", title);
        bodyMap.put("cover", cover);
        bodyMap.put("content", content);
        bodyMap.put("could_comment", could_comment);
        bodyMap.put("ctype", ctype);
        bodyMap.put("benefit", benefit);
        bodyMap.put("ext_tags", ext_tags);
        bodyMap.put("login_ids", login_ids);
        bodyMap.put("method", "alipay.open.public.message.content.create");
        Response response = new AlipayHttpsClient(super.alipay).post(bodyMap);
        //根据请求结果判定，是否验证成功
        JSONObject bodyRes = getObjRes(response, "alipay_open_public_message_content_create_response");
        if (Configuration.isDebug()) {
            System.out.println("alipay_open_public_message_content_create_response返回json：" + bodyRes.toString());
        }
        String codeRes = bodyRes.getString("code");
        if (ObjectHelper.isNotEmpty(codeRes)&&!"10000".equals(codeRes)) {
            String sub_code = bodyRes.getString("sub_code");
            String sub_msg = bodyRes.getString("sub_msg");
            //返回异常信息
            throw new AlipayException(getCause(sub_code,sub_msg));
        }
        return bodyRes;
    }
    
    
    /**
     * @Title: 更新图文消息内容接口
     * @Description: 开发者可使用该接口修改已经创建的生活号图文消息素材里的内容
     * @author heliang 
     * @param content_id 内容id
     * @param title 标题
     * @param cover 封面图url
     * @param content 消息正文（支持富文本） 
     * @param could_comment 是否允许评论 T:允许 F:不允许，默认不允许  T
     * @param ctype 图文类型 activity: 活动图文，不填默认普通图文
     * @param benefit 活动利益点，图文类型ctype为activity类型时才需要传，最多10个字符
     * @param ext_tags 关键词列表，英文逗号分隔，最多不超过5个
     * @param login_ids 可预览支付宝账号列表，需要预览时才填写， 英文逗号分隔，最多不超过10个
     * @return JSONObject: {"code": "10000","msg": "Success","content_id": "201410323232dsadjada-dsa-1234dsada","content_url": "alipays://xxxx"}
     * @throws AlipayException 
      */
    public JSONObject articleModify(String content_id,String title,String cover,String content,String could_comment,
            String ctype,String benefit,String ext_tags,String login_ids) throws AlipayException {
        if (ObjectHelper.isEmpty(content_id)) {
            throw new IllegalArgumentException("content_id can't be null or empty");
        }
        if (ObjectHelper.isEmpty(title)) {
            throw new IllegalArgumentException("title can't be null or empty");
        }
        if (ObjectHelper.isEmpty(cover)) {
            throw new IllegalArgumentException("cover can't be null or empty");
        }
        if (ObjectHelper.isEmpty(content)) {
            throw new IllegalArgumentException("content can't be null or empty");
        }
        //组装请求参数
        Map<String, String> bodyMap = new HashMap<String, String>();
        bodyMap.put("content_id", content_id);
        bodyMap.put("title", title);
        bodyMap.put("cover", cover);
        bodyMap.put("content", content);
        bodyMap.put("could_comment", could_comment);
        bodyMap.put("ctype", ctype);
        bodyMap.put("benefit", benefit);
        bodyMap.put("ext_tags", ext_tags);
        bodyMap.put("login_ids", login_ids);
        bodyMap.put("method", "alipay.open.public.message.content.modify");
        Response response = new AlipayHttpsClient(super.alipay).post(bodyMap);
        //根据请求结果判定，是否验证成功
        JSONObject bodyRes = getObjRes(response, "alipay_open_public_message_content_modify_response");
        if (Configuration.isDebug()) {
            System.out.println("alipay_open_public_message_content_modify_response返回json：" + bodyRes.toString());
        }
        String codeRes = bodyRes.getString("code");
        if (ObjectHelper.isNotEmpty(codeRes)&&!"10000".equals(codeRes)) {
            String sub_code = bodyRes.getString("sub_code");
            String sub_msg = bodyRes.getString("sub_msg");
            //返回异常信息
            throw new AlipayException(getCause(sub_code,sub_msg));
        }
        return bodyRes;
    }
    
}
